/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright @ Huawei Technologies Co., Ltd. 2022-2023. ALL rights reserved.
 * Description: Header file for hpmm persistent memory.
 */

#ifndef _LINUX_HPMM_PERSIST_H
#define _LINUX_HPMM_PERSIST_H

#include <linux/mm.h>
#include <linux/hpmm.h>
#include <linux/types.h>

struct hpmm_dev_node {
	/* the hpmm_device which this dev_node belonged to */
	struct list_head entry;
	/* the hpmm_dev_node is being used in corresponding persist */
	struct hpmm_persist_device *dev_node;
};

struct hpmm_persist_device {
	struct list_head list;
	/* the correspond hpmm_dev_nod */
	int node;
	spinlock_t dev_lock;
	/* the count of this hpmm_persist_device is being used. */
	atomic_t _refcount;
	/* bbu memory meta area addr */
	void *mgr_addr;
};

bool check_and_clear_meta(struct page *page);
struct hpmm_persist_device *find_hpmm_persist_device(int node);
void __init hpmm_persist_register(void);
void __exit hpmm_persist_unregister(void);

#endif /* _LINUX_HPMM_PERSIST_H */
